package demo;


import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * 代理公众号发起网页授权接口
 */
public class AuthorizeLinkManagerProxy {
	private static String component_appid = "wx964f044ff3a4e329";
	private static String appid = "wx655bc878f9572a43";
	private static String domain_name = "wushishen.imwork.net";
	private static String project_name = "wec";


	//获取公众号授权链接的方法
	public static String getOauthlink(String state){
		try {
			return oauthlinkPrefix + URLEncoder.encode(state,"utf-8") + oauthlinkSuffix;
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return null;
	}

	//获取代公众号网页授权的方法

		
	//授权链接前缀()
	private static String oauthlinkPrefix= "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appid+"&redirect_uri=http%3a%2f%2f"+domain_name+"%2f"+project_name+"%2fwxWebAuthProxy.do&response_type=code&scope=snsapi_userinfo&state=";
		
	//授权链接后缀
	private static String oauthlinkSuffix= "&component_appid="+component_appid+"#wechat_redirect";


	//H5
	private static  final String H5_DREAM= "/out/dream.do";

	public static  void main(String[] args){
        System.out.println(getOauthlink(H5_DREAM));
		//System.out.println("aa".contains("?"));

    }

}
